<?php
namespace app\common\service;
use \app\common\model\LitestoreShoporder as shopOrder ;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/8
 * Time: 15:33
 */
class LitestoreShopOrder extends Base {
    public function __construct()
    {
       $ShopOrderModel = new shopOrder();
       $this->model = $ShopOrderModel;
    }

    /**
     * 商家订单个人中心订单列表
     * @param $uid 支付用户id
     * @param $page 页数
     * @param $limit 加载条数
     * @param $status 订单状态参数
     * @return array 返回数组
     */
    public function ShopOrderList($uid,$page,$limit,$status){
       try{

           if($status==2){
               $map['comment_status'] = array('eq',0);
           }elseif($status==3){
           }else{
               $map['order_status'] = array('eq',$status);
           }
           $map['playUser_id']=array('eq',$uid);

           $order = 'shoporder_id desc';
           $data = $this->model
//               ->with('user')
               ->where($map)
               ->order($order)
               ->field('shoporder_id,litestore_shop_id,shop_name,play_time,play_name,total_price,comment_status,order_status,createtime')
               ->limit($limit)
               ->page($page)
               ->select();



//           $data =  collection($LitestoreOrderModel->with("orderLists")->select())->toArray();
//           $LitestoreShopComment = new LitestoreShopComment();
           //待评价
//           foreach($data as &$v){
//               foreach($v["order_lists"] as &$vv){
//                   $v['goods_name']=$vv['goods_name'];
//                   $v['goods_id']=$vv['goods_id'];
//                   $v['average'] =  $LitestoreShopComment->isComment($v['user_id'],$vv['goods_id']);
//               }
//               unset($v['order_lists']);
//           }

       }catch (\Exception $e){
           $data=[];
       }
       return $data;
    }
}